// calculator.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <conio.h>

#define VK_q 113
#define VK_w 119
#define VK_e 101

using namespace std;

string junk;


void text(string message)
{
	for(int i=0; i < message.length(); ++i)
	{
		Sleep(35);
		cout << message.c_str()[i];
	}
};
int f;
class silver_python;
class silver_sword;
class silver_crossbow;
class rifle;
class player 
{
public:

	string name;
	int health;
	int max_hp;
	int energy;
	int attype;
	int max_mana;
	int strength;
	int qtime;
	int ammo;
	int mana;
	int luck;
	int clash;
	int einput;


	void resetHealth ()
	{
		health=max_hp;
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
	}
	void resetmana ()
	{
		mana = max_mana;
		if (max_mana > 49);
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN );
	}
};
class guard 
{
public:

	string name;
	int health;
	int energy;
	int max_hp;
	int stealth;
	int strength;
	int stun;
	int ammo;
	int mana;
	int luck;

	void resetHealth ()
	{
		health=max_hp;
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
	}
};
void print_info(player player1)
//prints variable player1.health
{
	cout << player1.health;

}
void print_info(guard guard1)
{
	cout << guard1.health;
}
bool clash(player player1)
{
	bool clashing;

	if (player1.clash == 0)
		clashing = false;
	else
	{
		int random = rand()%10 + 1;
		if (random <= 1)
		{
			clashing = true;
			player1.clash = 0;
		}
		else
			clashing = false;
	}

	return clashing;
}
void fight(player player1, guard guard1)
{
	int random = rand()%10 + 1;
	if (random < 11)
	{
		string attack_type;
		cout << "a guard attacks you" << endl;
		do
		{
			cout << "choose how to attack" << endl;
			cin >> attack_type;
			//if they attack
			if (attack_type == "1")
			{
				int key = 0;
				int chosen_one = rand()%3 +1;

				if (chosen_one == 1)
				{
					cout << "press Q" <<endl;
				}

				if (chosen_one == 3)
				{
					cout << "press W" <<endl;
				}

				if (chosen_one == 2)
				{
					cout << "press E" <<endl;
				}

				getline (cin, junk);
				while (key != VK_q && key != VK_w && key != VK_e)
				{
					if (_kbhit)
					{
						key = getch();
						if (key == VK_q && chosen_one == 1)
						{
							guard1.health -= 20;
						
						}
						else if (key == VK_w && chosen_one == 3)
						{
							guard1.health -=20;
							
						}
						else if (key == VK_e && chosen_one == 2)
						{
							guard1.health -= 20;
							
						}
						else
						{
							player1.health -= 20;
							
						}
						break;
					}
				}

				if (player1.health <= 20 &&  player1.health >=1)

					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);

				else
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
				print_info (player1); 
				text (" player health\n");


				if (guard1.health <= 20 && player1.health <=1 )
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
				else
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
				print_info (guard1);
				text (" enemy health\n");
				if (guard1.health <1 )
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE);

				text (" enemy health\n");

			}
			else if (attack_type == "2" && player1.mana >=10)


			{

				guard1.health -= 10;
				player1.mana -= 10;
				text ("you burn your target and he slowly burns and stuff\n" );
				getline (cin, junk);


				{
					if (player1.health <= 20 &&  player1.health >=1)

						SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);

					else
						SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
					print_info (player1); 
					text (" player health\n");


					if (guard1.health <= 20 && player1.health <=1 )
						SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
					else
						SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
					print_info (guard1);
					text (" enemy health\n");
					if (guard1.health <1 )
						SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE);

					text (" enemy health\n");
					getline (cin , junk); 
				}
			}
			else if (attack_type == "3" && player1.mana >=50)
            
			{
			guard1.health -= 198560578995780;
			player1.mana -= 1;
			text ("your target is eaten by  crows\n" );
			getline (cin, junk);
			}
		}
		while(player1.health>0 && guard1.health>0); 
	
		player1.resetHealth();
		player1.resetmana();

	}
}
int _tmain(int argc, _TCHAR* argv[]){

	string enter;
	bool kill_Boze;
	int decision;
	double a;
	double b;
	string choice;
	player player1;
	player1.health=100;
	player1.max_hp=100;
	player1.max_mana = 10;
	player1.strength=20;
	player1.energy=10;
	player1.mana=10;
	player1.luck=20;
	player1.clash=1;
	srand(time(NULL));
	string attributes[5] = {"health", "stealth", "strength", "aim", "mana"}; 
	guard guard1;
	guard1.health=90;
	guard1.strength=20;
	guard1.mana=10;

	text("welcome to project #1.\n");
	cout << "\n.";

	text("project #1 - enter name below.\n");
	getline (cin , player1.name); 	
	cout << "hello, welcome to project #1, " << player1.name <<endl;

	string AI;
	cout << "what do you want to call me?" <<endl;
	getline(cin,AI);
	cout << "now my name is " << AI <<endl;

	do
	{
		cout << "what program do you want to use? to see programs ask your AI\n";
		getline(cin, choice);

		if (choice == "calculator")
		{
			cout << " ENTER FIRST NUMBER " <<endl <<" ";
			cin >> a;
			cout << " first number is " <<a<<endl;

			cout << " ENTER SECOND NUMBER "<<endl <<" ";
			cin >> b;


			cout << " enter your choice (add or divide, ec.) " <<endl;
			cin >> choice;

			if (choice == "add") 
			{

				cout << " the answer is " <<a + b <<"\n\n";

			}

			else if (choice == "subtract")
			{

				cout << " the answer is " <<a - b <<"\n\n";

			}
			else if (choice == "divide")
			{

				cout << " the answer is " <<a / b <<"\n\n";


			}
			else if (choice == "multiply")


			{

				cout << " the answer is " <<a * b <<"\n\n";


			}
			else
			{
				cout<< "incorrect option redirecting to program start";
			}
		}
		else if (choice == ("ask " + AI));

		{
			if (choice == "list programs")
			{
				cout << " calcultor - calculates simple equations \n  zrun - play adenture game " <<endl;
			}
			else if (choice == "change settings")
			{
				cout << "change AI name" << endl;
				getline (cin , AI);

				cout << "would you like me to LIST PROGRAMS, or to CHANGE SETTINGS? " <<endl;
				cout << "change name" << endl;
				getline (cin , player1.name); 

			}
			else if (choice == "spam" )
			{
				string number;
				cout <<"enter thier number" <<endl;
				cin >> number ;
				text ("calling number");
				getline (cin, junk);
				cout <<"system overload"<<endl;
				Beep (1000,1000);
				do
					{
						int rnumb = rand()%9 +1;
						cout << rnumb;
					}
				     while (guard1.health != 234566756);
			}
			else if (choice == "zrun")
			{
				cout << "you have finnally arrived at your home, and the royal bodygaurd of the emperess Kiliea" <<endl;
				getline (cin,enter);
				cout << "you enter the dining hall with the emperess and General Boze to talk about the \n possible attack on the swamplands, a land Bolthia knows little of." <<endl;
				getline (cin,enter);
				cout << "general-' hello Empress we must discuss important matters, about the attack '" <<endl;
				getline (cin,enter);
				cout << "emperess-' we cant do it, our city can not have another enemy!'" << endl;
				getline (cin,enter);
				cout << "general-' no i must have this land, the gold mines will provide money for the whole city'" << endl; 
				getline (cin,enter);
				cout << "general-' i am afraid your death is the only way '" << endl;
				getline (cin,enter);
				cout << " he takes out a silver-python pistol and aims it at the emperess" << endl;
				getline (cin,enter);
				cout << "attack the general (1) or save the emperess (2)? " << endl;
				cin >>decision;
				if (decision=1)
				{
					player1.luck += 10;
					cout << "+10 strength_rep" <<endl;
					getline (cin,enter);
					cout <<" you take gun gun out of his hand and aim it a him, as this happens you turn cold at learn that you cant move your legs" <<endl;
					getline (cin,enter);
					cout << " he takes the gun and shoots the empress who falls to your knees, soon gaurds fill the room and take you " <<endl;
					getline (cin,enter);
					cout << "guard-'i cant believe her own bodygaurd killed her'" <<endl;
					getline (cin,junk);
					cout << " right before you are dumped into the river, you are knocked out and poisoned" <<endl;
					cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" <<endl;
					text ("you wake up with a guard walking torward you, as you try to move you realize that you leg is stuck in a snare trap");
					getline (cin,junk);
					text ("a bottle lies near you next to what seems to be a dead native, seeing no choice you drink the bottle.");
					getline (cin,junk);
					text ("as the guard grabs your hand, his body burns in flames and he dies");
					getline (cin,junk);
					text ("after lotting a nearby empty camp, you start your journey");
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					text (" the last guard was BOZE, you win now, you can kill every think with your superspell? ");\
						player1.mana +=800;
					player1.max_mana +=800;
					fight (player1,guard1);		
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);		
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);
					while ( player1.health > 0 );
					fight (player1,guard1);

				}

				if (decision==2)
				{
					int random = rand()%5 + 1;
					cout << "hidden atribute +10" <<endl;
					if (random==1)
					{
						player1.strength += 10;
					}
					if (random==2)
					{
						player1.health += 10;
						player1.max_hp += 10;
					}
					if (random==3)
					{
						player1.mana +=10;
						player1.max_mana +=10;
					}
					if (random==4)
					{
						player1.mana =+ 10;
					}
					if (random==5)
					{
						player1.strength =+ 2;
					}
				}


			}
			else
			{
				cout << " program non existent" <<endl;
			}
			cin.ignore(1000, '\n');
		}}
	while (choice != "quit");


	return 0;
}